package com.ssy.lingxi.transaction.repository;

import com.ssy.lingxi.transaction.entity.InquiryProduct;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
*询价单商品
* @author wrc
* @date 2020/7/8
*/
@Repository
public interface InquiryProductRepository extends JpaRepository<InquiryProduct, Long>, JpaSpecificationExecutor<InquiryProduct> {
    /**
    * 根据询价单ID查询商品列表
    * @author wrc
    * @date 2020/8/10
    */
    List<InquiryProduct> findAllByInquiryIdEquals(Long inquiryId);

    /**
    * 根据询价报价单Id查询单据详情
    * @author wrc
    * @date 2020/11/6
    */
    Page<InquiryProduct> findByInquiryId(Long inquiryId, Pageable page);

    /**
    * 根据询价报价单Id查询单据详情
    * @author wrc
    * @date 2020/11/6
    */
    Page<InquiryProduct> findAllByQuoteIdEquals(Long productQuotationId, Pageable page);

    void deleteAllByInquiryIdEquals(Long inquiryId);

    void deleteAllByInquiryIdIn(List<Long> inquiryIds);

    List<InquiryProduct> findAllByQuoteId(Long productQuotationId);

    InquiryProduct findFirstByInquiryId(Long inquiryId);

    List<InquiryProduct> findByProductIdInAndQuoteIdInOrderByCreateTimeDesc(List<Long> skuIdList, List<Long> quoteIdList);
}
